<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <title>FindOpenGL &mdash; CMake 4.1.1 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=a2c47e09" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css?v=4d06bd55" />
    
    <script src="../_static/documentation_options.js?v=e6a937a4"></script>
    <script src="../_static/doctools.js?v=9bcbadda"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="FindOpenMP" href="FindOpenMP.html" />
    <link rel="prev" title="FindOpenCL" href="FindOpenCL.html" />
 

  </head><body>
    <input id="sidebar-check" type="checkbox" />
    <label id="sidebar-overlay" for="sidebar-check"></label>



    <div class="related relbar1" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="FindOpenMP.html" title="FindOpenMP"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="FindOpenCL.html" title="FindOpenCL"
             accesskey="P">previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" accesskey="U">cmake-modules(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">FindOpenGL</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="findopengl">
<span id="module:FindOpenGL"></span><h1>FindOpenGL<a class="headerlink" href="#findopengl" title="Link to this heading">¶</a></h1>
<p>FindModule for OpenGL and OpenGL Utility Library (GLU).</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.2: </span>X11 is no longer added as a dependency on Unix/Linux systems.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.10: </span>GLVND support on Linux.  See the <a class="reference internal" href="#linux-specific"><span class="std std-ref">Linux-specific</span></a> section below.</p>
</div>
<section id="optional-components">
<h2>Optional COMPONENTS<a class="headerlink" href="#optional-components" title="Link to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.10.</span></p>
</div>
<p>This module respects several optional COMPONENTS:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">EGL</span></code></dt><dd><p>The EGL interface between OpenGL, OpenGL ES and the underlying windowing system.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">GLX</span></code></dt><dd><p>An extension to X that interfaces OpenGL, OpenGL ES with X window system.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL</span></code></dt><dd><p>The cross platform API for 3D graphics.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">GLES2</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.27.</span></p>
</div>
<p>A subset of OpenGL API for embedded systems with limited capabilities.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">GLES3</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.27.</span></p>
</div>
<p>A subset of OpenGL API for embedded systems with more capabilities.</p>
</dd>
</dl>
</section>
<section id="imported-targets">
<h2>Imported Targets<a class="headerlink" href="#imported-targets" title="Link to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.8.</span></p>
</div>
<p>This module defines the <span class="target" id="index-0-prop_tgt:IMPORTED"></span><a class="reference internal" href="../prop_tgt/IMPORTED.html#prop_tgt:IMPORTED" title="IMPORTED"><code class="xref cmake cmake-prop_tgt docutils literal notranslate"><span class="pre">IMPORTED</span></code></a> targets:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL::GL</span></code></dt><dd><p>Defined to the platform-specific OpenGL libraries if the system has OpenGL.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL::GLU</span></code></dt><dd><p>Defined if the system has OpenGL Utility Library (GLU).</p>
</dd>
</dl>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.10: </span>Additionally, the following GLVND-specific library targets are defined:</p>
</div>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL::OpenGL</span></code></dt><dd><p>Defined to libOpenGL if the system is GLVND-based.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL::GLX</span></code></dt><dd><p>Defined if the system has OpenGL Extension to the X Window System (GLX).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL::EGL</span></code></dt><dd><p>Defined if the system has EGL.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL::GLES2</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.27.</span></p>
</div>
<p>Defined if the system has GLES2.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL::GLES3</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.27.</span></p>
</div>
<p>Defined if the system has GLES3.</p>
</dd>
</dl>
</section>
<section id="result-variables">
<h2>Result Variables<a class="headerlink" href="#result-variables" title="Link to this heading">¶</a></h2>
<p>This module sets the following variables:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_FOUND</span></code></dt><dd><p>True, if the system has OpenGL and all components are found.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_XMESA_FOUND</span></code></dt><dd><p>True, if the system has XMESA.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_GLU_FOUND</span></code></dt><dd><p>True, if the system has GLU.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL_OpenGL_FOUND</span></code></dt><dd><p>True, if the system has an OpenGL library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL_GLX_FOUND</span></code></dt><dd><p>True, if the system has GLX.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL_EGL_FOUND</span></code></dt><dd><p>True, if the system has EGL.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL::GLES2</span></code></dt><dd><p>Defined if the system has GLES2.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenGL::GLES3</span></code></dt><dd><p>Defined if the system has GLES3.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_INCLUDE_DIR</span></code></dt><dd><p>Path to the OpenGL include directory.
The <code class="docutils literal notranslate"><span class="pre">OPENGL_INCLUDE_DIRS</span></code> variable is preferred.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_EGL_INCLUDE_DIRS</span></code></dt><dd><p>Path to the EGL include directory.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_LIBRARIES</span></code></dt><dd><p>Paths to the OpenGL library, windowing system libraries, and GLU libraries.
On Linux, this assumes GLX and is never correct for EGL-based targets.
Clients are encouraged to use the <code class="docutils literal notranslate"><span class="pre">OpenGL::*</span></code> import targets instead.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_INCLUDE_DIRS</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.29.</span></p>
</div>
<p>Paths to the OpenGL include directories.</p>
</dd>
</dl>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.10: </span>Variables for GLVND-specific libraries <code class="docutils literal notranslate"><span class="pre">OpenGL</span></code>, <code class="docutils literal notranslate"><span class="pre">EGL</span></code> and <code class="docutils literal notranslate"><span class="pre">GLX</span></code>.</p>
</div>
</section>
<section id="cache-variables">
<h2>Cache variables<a class="headerlink" href="#cache-variables" title="Link to this heading">¶</a></h2>
<p>The following cache variables may also be set:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_egl_LIBRARY</span></code></dt><dd><p>Path to the EGL library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_glu_LIBRARY</span></code></dt><dd><p>Path to the GLU library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_glx_LIBRARY</span></code></dt><dd><p>Path to the GLVND 'GLX' library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_opengl_LIBRARY</span></code></dt><dd><p>Path to the GLVND 'OpenGL' library</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_gl_LIBRARY</span></code></dt><dd><p>Path to the OpenGL library.  New code should prefer the <code class="docutils literal notranslate"><span class="pre">OpenGL::*</span></code> import
targets.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_gles2_LIBRARY</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.27.</span></p>
</div>
<p>Path to the OpenGL GLES2 library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_gles3_LIBRARY</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.27.</span></p>
</div>
<p>Path to the OpenGL GLES3 library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENGL_GLU_INCLUDE_DIR</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.29.</span></p>
</div>
<p>Path to the OpenGL GLU include directory.</p>
</dd>
</dl>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.10: </span>Variables for GLVND-specific libraries <code class="docutils literal notranslate"><span class="pre">OpenGL</span></code>, <code class="docutils literal notranslate"><span class="pre">EGL</span></code> and <code class="docutils literal notranslate"><span class="pre">GLX</span></code>.</p>
</div>
</section>
<section id="linux-specific">
<span id="id1"></span><h2>Linux-specific<a class="headerlink" href="#linux-specific" title="Link to this heading">¶</a></h2>
<p>Some Linux systems utilize GLVND as a new ABI for OpenGL.  GLVND separates
context libraries from OpenGL itself; OpenGL lives in &quot;libOpenGL&quot;, and
contexts are defined in &quot;libGLX&quot; or &quot;libEGL&quot;.  GLVND is currently the only way
to get OpenGL 3+ functionality via EGL in a manner portable across vendors.
Projects may use GLVND explicitly with target <code class="docutils literal notranslate"><span class="pre">OpenGL::OpenGL</span></code> and either
<code class="docutils literal notranslate"><span class="pre">OpenGL::GLX</span></code> or <code class="docutils literal notranslate"><span class="pre">OpenGL::EGL</span></code>.</p>
<p>Projects may use the <code class="docutils literal notranslate"><span class="pre">OpenGL::GL</span></code> target (or <code class="docutils literal notranslate"><span class="pre">OPENGL_LIBRARIES</span></code> variable)
to use legacy GL interfaces.  These will use the legacy GL library located
by <code class="docutils literal notranslate"><span class="pre">OPENGL_gl_LIBRARY</span></code>, if available.  If <code class="docutils literal notranslate"><span class="pre">OPENGL_gl_LIBRARY</span></code> is empty or
not found and GLVND is available, the <code class="docutils literal notranslate"><span class="pre">OpenGL::GL</span></code> target will use GLVND
<code class="docutils literal notranslate"><span class="pre">OpenGL::OpenGL</span></code> and <code class="docutils literal notranslate"><span class="pre">OpenGL::GLX</span></code> (and the <code class="docutils literal notranslate"><span class="pre">OPENGL_LIBRARIES</span></code>
variable will use the corresponding libraries).  Thus, for non-EGL-based
Linux targets, the <code class="docutils literal notranslate"><span class="pre">OpenGL::GL</span></code> target is most portable.</p>
<p>A <code class="docutils literal notranslate"><span class="pre">OpenGL_GL_PREFERENCE</span></code> variable may be set to specify the preferred way
to provide legacy GL interfaces in case multiple choices are available.
The value may be one of:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">GLVND</span></code></dt><dd><p>If the GLVND OpenGL and GLX libraries are available, prefer them.
This forces <code class="docutils literal notranslate"><span class="pre">OPENGL_gl_LIBRARY</span></code> to be empty.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.11: </span>This is the default, unless policy <span class="target" id="index-0-policy:CMP0072"></span><a class="reference internal" href="../policy/CMP0072.html#policy:CMP0072" title="CMP0072"><code class="xref cmake cmake-policy docutils literal notranslate"><span class="pre">CMP0072</span></code></a> is set to <code class="docutils literal notranslate"><span class="pre">OLD</span></code>
and no components are requested (since components
correspond to GLVND libraries).</p>
</div>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">LEGACY</span></code></dt><dd><p>Prefer to use the legacy libGL library, if available.</p>
</dd>
</dl>
<p>For EGL targets the client must rely on GLVND support on the user's system.
Linking should use the <code class="docutils literal notranslate"><span class="pre">OpenGL::OpenGL</span> <span class="pre">OpenGL::EGL</span></code> targets.  Using GLES*
libraries is theoretically possible in place of <code class="docutils literal notranslate"><span class="pre">OpenGL::OpenGL</span></code>, but this
module does not currently support that; contributions welcome.</p>
<p><code class="docutils literal notranslate"><span class="pre">OPENGL_egl_LIBRARY</span></code> and <code class="docutils literal notranslate"><span class="pre">OPENGL_EGL_INCLUDE_DIRS</span></code> are defined in the case of
GLVND.  For non-GLVND Linux and other systems these are left undefined.</p>
</section>
<section id="macos-specific">
<h2>macOS-Specific<a class="headerlink" href="#macos-specific" title="Link to this heading">¶</a></h2>
<p>On macOS this module defaults to using the macOS-native framework
version of OpenGL.  To use the X11 version of OpenGL on macOS, one
can disable searching of frameworks.  For example:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">find_package(</span><span class="no">X11</span><span class="nf">)</span>
<span class="nf">if(</span><span class="no">APPLE</span><span class="w"> </span><span class="no">AND</span><span class="w"> </span><span class="no">X11_FOUND</span><span class="nf">)</span>
<span class="w">  </span><span class="nf">set(</span><span class="no">CMAKE_FIND_FRAMEWORK</span><span class="w"> </span><span class="no">NEVER</span><span class="nf">)</span>
<span class="w">  </span><span class="nf">find_package(</span><span class="nb">OpenGL</span><span class="nf">)</span>
<span class="w">  </span><span class="nf">unset(</span><span class="no">CMAKE_FIND_FRAMEWORK</span><span class="nf">)</span>
<span class="nf">else()</span>
<span class="w">  </span><span class="nf">find_package(</span><span class="nb">OpenGL</span><span class="nf">)</span>
<span class="nf">endif()</span>
</pre></div>
</div>
<p>An end user building this project may need to point CMake at their
X11 installation, e.g., with <code class="docutils literal notranslate"><span class="pre">-DOpenGL_ROOT=/opt/X11</span></code>.</p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3>Table of Contents</h3>
    <ul>
<li><a class="reference internal" href="#">FindOpenGL</a><ul>
<li><a class="reference internal" href="#optional-components">Optional COMPONENTS</a></li>
<li><a class="reference internal" href="#imported-targets">Imported Targets</a></li>
<li><a class="reference internal" href="#result-variables">Result Variables</a></li>
<li><a class="reference internal" href="#cache-variables">Cache variables</a></li>
<li><a class="reference internal" href="#linux-specific">Linux-specific</a></li>
<li><a class="reference internal" href="#macos-specific">macOS-Specific</a></li>
</ul>
</li>
</ul>

  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="FindOpenCL.html"
                          title="previous chapter">FindOpenCL</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="FindOpenMP.html"
                          title="next chapter">FindOpenMP</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/module/FindOpenGL.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="FindOpenMP.html" title="FindOpenMP"
             >next</a> |</li>
        <li class="right" >
          <a href="FindOpenCL.html" title="FindOpenCL"
             >previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" >cmake-modules(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">FindOpenGL</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
    &#169; Copyright 2000-2025 Kitware, Inc. and Contributors.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
    </div>
<script type="text/javascript">
(function() {
  "use strict";
  const hide = () => document.getElementById("sidebar-check").checked = false;
  addEventListener("keydown", e => (e.key === "Escape") && hide());
  addEventListener("click", e => (e.target.tagName === "A") && hide());
  addEventListener("hashchange", hide)
})();
</script>
  </body>
</html>